package com.hnevc.yinqi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hnevc.yinqi.R;

public class MyAdapter extends BaseAdapter {
    Context context;
    String[] shunxus;
    int[] imgs;
    String[] guojias;


    public MyAdapter(Context context, String[] shunxus, int[] imgs, String[] guojias) {
        this.context = context;
        this.shunxus = shunxus;
        this.imgs = imgs;
        this.guojias = guojias;
    }

    @Override
    public int getCount() {
        return shunxus.length;
    }

    @Override
    public Object getItem(int position) {
        return shunxus[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(context, R.layout.listview_item_layout,null);
            TextView shunxuTv = convertView.findViewById(R.id.shunxu);
            ImageView imgTv = convertView.findViewById(R.id.img);
            TextView guojiaTv = convertView.findViewById(R.id.guojia);
            shunxuTv.setText(shunxus[position]);
            imgTv.setImageResource(imgs[position]);
            guojiaTv.setText(guojias[position]);

        }
        return convertView;
    }
}
